package com.glsc.ngateway.common.base.repo.mysql.gateway.platform.it;


import com.glsc.ngateway.common.base.domain.mysql.gateway.platform.it.ItDict;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;


@Repository
public interface ItDictRepo extends JpaRepository<ItDict, Integer> {

    ItDict findByZdId(Integer zdId);


    //"select a.zd_id,a.dict_value from t_dict a,t_dictdata b where a.dict_entry=b.dict_id and b.dict_data=?";
    // "select m from ItNetworkDevice m where 1=1 and (:userid is null OR m.userId = :userid)  order by m.insertTime desc")
    @Query("select a from ItDict a,ItDictData b where a.dictEntry = b.dictId and b.dictData = :dictData ")
    Page<ItDict> getDict(Pageable pageable, String dictData);

    @Query("select a from ItDict a where a.dictEntry = :dictData ")
    List<ItDict> getDicts(String dictData);

    List<ItDict> findByDictEntryAndDictSubentry(String dictEntry, String dictSubentry);
}
